home *** CD-ROM | disk | FTP | other *** search
/ Wonky Flux Batch 2019 02 / Wonky_Flux_Batch_2019-02.zip / Wonky Flux Batch 2019-02 / 075 - Clash of Arms.dsk / WAR.MOVE2.S < prev    next >
Text File  |  2019-02-17  |  23KB  |  601 lines

  1.           on nocar goto link.term
  2.           use "a:scroll.dn"
  3.           ch$=pc$:sy=2
  4.           open #1,"h:war.map1":open #2,"h:war.map2"
  5.           gosub scanmap
  6.           close #1:open #1,"H:COORDS"
  7.           position #1,8,0:input #1 ky,ky
  8.           if ky<24 ma=0:mp=0:bo=24:yy=2:yo=2:tp=1:else mp=1:bo=47:yy=25:yo=25:ma=1:tp=24
  9.           close
  10.           open #1,"h:war.map1":open #2,"h:war.map2"
  11.           xx=1:xo=1:so=2:ta=1
  12.           gosub pmap
  13.  
  14.  
  15. MainLoop
  16.           gosub SetAttacksZero
  17.           gosub Split
  18.           gosub readcoords
  19.           gosub Merge
  20.           link "a:war.start","quitgame"
  21.  
  22. SetAttacksZero
  23.           close #1:open #1,"h:attacks"
  24.           p1=asc(ch$)-97
  25.           for p2=0 to 5
  26.           position #1,60,p2,p1*10
  27.           print #1,0
  28.           next
  29.           close #1:open #1,"h:war.map1"
  30.           return
  31.  
  32. Merge
  33.           x=40:y=24:gosub screen:print "Merge armies ? (Y/[N])                  ";
  34.           gosub getkey
  35.           if (ka$<>"Y") and (ka$<>"y") return
  36.           y=yy:gosub getline1:x=xx:y=sy:gosub screen:gosub invon:print mid$(l1$,xx,1);:gosub invoff
  37.           create "h:merges"
  38.           close #1:open #1,"h:merges":print #1,0:print #1,0:close #1:open #1,"h:war.map1"
  39. Merge1
  40.           x=40:y=24:gosub screen:print "Source. <cr> selects, <ESC> exits merge ";
  41. Merge1.1
  42.           xo=xx:yo=yy:so=sy:x=xx:y=sy:gosub screen
  43.           gosub MapMove
  44.           if ka$=chr$(27) goto MergeEnd
  45.           aa$=mid$(l1$,xx,1)
  46.           if instr(aa$,ch$) kk=1:else kk=0
  47.           gosub armystrength:bb$=mid$(l2$,xx,1):bb=ar
  48.           if (bb=0) or (kk=0) x=40:y=24:gosub screen:print "No armies there.                        ";:goto merge1.1
  49.           close #1:open #1,"h:merges":dd=0
  50. Merge1.2
  51.           input #1,x:input #1,y:if (x=xx) and (y=yy) dd=1
  52.           if not (eof(1)) goto merge1.2
  53.           close #1:open #1,"h:war.map1"
  54.           if dd=1 x=40:y=24:gosub screen:print "That army has already merged.           ";:goto merge1.1
  55.           xf=xx:yf=yy:ke=sy
  56.           x=40:y=24:gosub screen:print "Destination. <cr> selects, <ESC> aborts";
  57. Merge2
  58.           x=xx:y=sy:xo=xx:yo=yy:so=sy:gosub screen
  59.           gosub MapMove
  60.           if ka$=chr$(27) goto Merge1
  61.           if (xx=xf) and (yy=yf) goto Merge1
  62.           if xx>xf dx=xx-xf:else dx=xf-xx
  63.           if yy>yf dy=yy-yf:else dy=yf-yy
  64.           if (dx>1) or (dy>1) x=40:y=24:gosub screen:print "Not within 1 square                     ";:goto Merge2
  65.           y=yy:c$=mid$(l1$,xx,1)
  66.           if instr(c$,ch$) kk=1:else kk=0
  67.           gosub armystrength:dd=ar:dd$=mid$(l2$,xx,1)
  68.           if (dd=0) or (kk=0) x=40:y=24:gosub screen:print "No armies there.                        ";:goto merge2
  69.           mx=9-dd
  70. Merge3
  71.           x=40:y=24:gosub screen:print "How many? (0-"bb", max of "mx")              ";chr$(8);
  72.           get ka$:ka=val(ka$):if ka=0 goto merge1
  73.           if (ka>bb) or (ka<0) goto merge3
  74.           if ka>mx goto merge3
  75.           bb=bb-ka
  76.           dd=dd+ka
  77.           if (bb=0) and (asc(aa$)>96) and (asc(bb$)<64) aa$=" "
  78.           if (bb=0) and (asc(aa$)>96) and (asc(bb$)>64) aa$="+"
  79.           if (asc(bb$)>64) and (bb>0) bb$=chr$(bb+64):else bb$=chr$(bb+48)
  80.           if (asc(dd$)>64) dd$=chr$(dd+64):else dd$=chr$(dd+48)
  81.           position #1,80,yf-1,xf-1:print #1,aa$;
  82.           position #2,80,yf-1,xf-1:print #2,bb$;
  83.           position #2,80,yy-1,xx-1:print #2,dd$;
  84.           close #1:open #1,"h:merges":append #1
  85.           print #1,xx:print #1,yy:close #1:open #1,"h:war.map1"
  86.           x=9:y=24:gosub screen:print dd;" ";
  87.           x=xf:y=ke:gosub screen:print aa$;
  88.           goto merge1
  89.  
  90. MergeEnd
  91.           kill "h:merges"
  92.           x=xx:y=yy:gosub getline1
  93.           y=sy:gosub screen:gosub invoff:print mid$(l1$,xx,1);:return
  94.  
  95. Split
  96.           x=40:y=24:gosub screen:print "Split armies ? (Y/[N])                  ";
  97.           gosub getkey
  98.           if (ka$<>"Y") and (ka$<>"y") return
  99.           y=yy:gosub getline1:x=xx:y=sy:gosub screen:gosub invon:print mid$(l1$,xx,1);:gosub invoff
  100.           create "h:splits"
  101.           close #1:open #1,"h:splits":print #1,0:print #1,0:close #1:open #1,"h:war.map1"
  102. Split1
  103.           x=40:y=24:gosub screen:print "Source. <cr> selects, <ESC> exits split ";
  104. Split1.1
  105.           xo=xx:yo=yy:so=sy:x=xx:y=sy:gosub screen
  106.           gosub MapMove
  107.           if ka$=chr$(27) goto SplitEnd
  108.           aa$=mid$(l1$,xx,1)
  109.           if instr(aa$,ch$) kk=1:else kk=0
  110.           gosub armystrength:bb$=mid$(l2$,xx,1):bb=ar
  111.           if (bb<2) or (kk=0) x=40:y=24:gosub screen:print "Not enough armies there.               ";:goto split1.1
  112.           close #1:open #1,"h:splits":dd=0
  113. Split1.2
  114.           input #1,x:input #1,y:if (x=xx) and (y=yy) dd=1
  115.           if not (eof(1)) goto split1.2
  116.           close #1:open #1,"h:war.map1"
  117.           if dd=1 x=40:y=24:gosub screen:print "That army has already split.           ";:goto split1.1
  118.           xf=xx:yf=yy
  119.           x=40:y=24:gosub screen:print "Destination. <cr> selects, <ESC> aborts";
  120. Split2
  121.           x=xx:y=sy:xo=xx:so=sy:yo=yy:gosub screen
  122.           gosub MapMove
  123.           if ka$=chr$(27) goto Split1
  124.           if (xx=xf) and (yy=yf) goto Split1
  125.           if xx>xf dx=xx-xf:else dx=xf-xx
  126.           if yy>yf dy=yy-yf:else dy=yf-yy
  127.           if (dx>1) or (dy>1) x=40:y=24:gosub screen:print "Not within 1 square                     ";:goto Split2
  128.           y=yy:c$=mid$(l1$,xx,1)
  129.           if (c$=":") and (bb<9) x=40:y=24:gosub screen:print "Not enough armies for a boat.           ";:gosub getkey:goto Split1
  130.           if c$=":" x=40:y=24:gosub screen:print "Create Boat? ([Y]/N)                    ";:gosub getkey:if ka$="N" goto Split1
  131.           if instr(c$,"#=*") kk=1:else kk=0
  132.           gosub armystrength:dd=ar:dd$=mid$(l2$,xx,1)
  133.           if (dd>0) or (kk=1) x=40:y=24:gosub screen:print "That space taken.                       ";:goto split2
  134. Split3
  135.           if c$=":" bb=bb-8:aa$="+":dd$="0":if (asc(bb$)>64) bb$=chr$(bb+64):else bb$=chr$(bb+48)
  136.           if c$=":" gosub upboat:goto splitsave
  137.           x=40:y=24:gosub screen:print "How many? (1-"bb-1")                        ";chr$(8);
  138.           get ka$:ka=val(ka$):if ka=0 goto split1
  139.           if (ka>bb-1) or (ka<0) goto split3
  140.           bb=bb-ka
  141.           dd=ka
  142.           if asc(aa$)<96 aa$=chr$(asc(aa$)+32)
  143.           if (asc(bb$)>64) bb$=chr$(bb+64):else bb$=chr$(bb+48)
  144.           if c$="+" dd$=chr$(dd+64):else dd$=chr$(dd+48)
  145.           if ((asc(c$)>64) and (asc(c$)<91)) or (c$="*") aa$=chr$(asc(aa$)-32)
  146. splitsave
  147.           position #1,80,yy-1,xx-1:print #1,aa$;
  148.           position #2,80,yf-1,xf-1:print #2,bb$;
  149.           position #2,80,yy-1,xx-1:print #2,dd$;
  150.           close #1:open #1,"h:splits":append #1
  151.           print #1,xx:print #1,yy:close #1:open #1,"h:war.map1"
  152.           x=9:y=24:gosub screen:print dd;" ";
  153.           x=xx:y=sy:gosub screen:gosub invon:print aa$;:gosub invoff
  154.           goto split1
  155.  
  156. SplitEnd
  157.           kill "h:splits"
  158.           x=xx:y=yy:gosub getline1:y=sy:gosub screen:gosub invoff
  159.           print mid$(l1$,xx,1);:return
  160.  
  161. scr1
  162.           kb=yy:kd=tp
  163.           if tp<>yy then for ka=1 to (tp-yy):yy=(kd-ka)+1:gosub scrolldown:next:yy=yy-1
  164.           if yy>=2:gosub scrolldown
  165.           yy=kb:tp=yy-1:return
  166. scr2
  167.           kb=yy:kd=tp+22
  168.           if kd=yy gosub scrollup:tp=yy-21:return
  169.           for ka=1 to (yy-kd):yy=(kd+ka)-1:gosub scrollup:next:yy=yy+1
  170.           if yy<=45 gosub scrollup
  171.           yy=kb:tp=yy-21:return
  172. search
  173.           kx=xx:ky=yy:gosub mapmove
  174.           gosub erase
  175.           xx=kx:yy=ky
  176.           if yy<=tp gosub scr1:else if yy=>(tp+22) gosub scr2
  177.           sy=(yy-tp)+1
  178.           y=sy:gosub flsh
  179.           goto Move1
  180.  
  181. flsh
  182.           y=yy:gosub getline1
  183.           y=sy
  184.           x=xx:aa$=mid$(l1$,xx,1)
  185.           for kz=1 to 3
  186.           gosub screen:gosub invon:print aa$;
  187.           gosub screen:gosub invoff:print aa$;
  188.           next
  189.           gosub screen:gosub invon:print aa$;chr$(8);:gosub invoff
  190.           return
  191.  
  192. Move
  193.           y=yy:gosub getline1
  194.           if yy=<tp gosub scr1:else if yy=>(tp+22) gosub scr2
  195.           sy=(yy-tp)+1:y=sy
  196.           gosub flsh
  197.           count=1
  198. Move1
  199.           y=yy:gosub getline1:y=sy:x=xx:gosub screen:gosub invon:print mid$(l1$,xx,1);chr$(8);:gosub invoff
  200.           gosub armystrength:as=ar:gosub getline1
  201.           aa$=mid$(l1$,xx,1):bb$=mid$(l2$,xx,1)
  202.           if instr(bb$,"ABCDEFGHI") bt=1:else bt=0
  203.           xf=xx:yf=yy:ys=sy
  204.           x=40:y=bo:gosub screen:print "Move "count"("nm"),< > Select,ESC-abort,S-search ";
  205. Move2
  206.           x=9:y=24:gosub screen:gosub armystrength:print ar;" ";
  207.           gosub getterrain:x=24:y=24:gosub screen:print ms$;
  208.           xo=xx:so=sy:yo=yy:x=xx:y=sy:gosub screen:ok=1:gosub mapmove
  209.           if (kc>1) and ((ka$="<") or (ka$=",")) kd=kc:goto sback0
  210.           if (kc<nb) and ((ka$=">") or (ka$=".")) gosub scanforw:return
  211.           if instr(ka$,",.<>") goto move2
  212.           if ka$="S" x=40:y=24:gosub screen:ok=0:print "Search Map Mode.  <ESC> to abort        ";:goto Search
  213.           if xx>xf dx=xx-xf:else dx=xf-xx
  214.           if yy>yf dy=yy-yf:else dy=yf-yy
  215.           y=yy:gosub getline1:c$=mid$(l1$,xx,1)
  216.           if (count=1) and (ka$=chr$(27)) ta=ta+1
  217.           if ka$=chr$(27) x=xx:y=sy:gosub screen:print c$;:gosub zerocoords:return
  218.           if (dx>1) or (dy>1) x=40:y=24:gosub screen:print "Not within 1 square                     ";:gosub erase:xx=xf:yy=yf:sy=ys:gosub flsh:goto Move2
  219.           if (xx=xf) and (yy=yf) gosub showchar:return
  220.           if instr(c$,"=#") x=40:y=24:gosub screen:print "Impassable                              ";:gosub erase:xx=xf:yy=yf:sy=ys:gosub flsh:goto move2
  221.           if (c$=":") and (bt=0) x=40:y=24:gosub screen:print "Need a boat.                            ";:gosub erase:xx=xf:yy=yf:sy=ys:gosub flsh:goto move2
  222.           if instr(aa$,c$) y=yy:gosub getline2: if mid$(l2$,xx,1)<>"0" x=40:y=24:gosub screen:print "No stacking while moving.               ";:gosub erase:xx=xf:yy=yf:sy=ys:gosub flsh:goto move2
  223.           if instr(c$,"ABCDEF") kk=1:else kk=0
  224.           if (kk=1) and (aa$<>c$) and (aa$<>chr$(asc(c$)+32)) goto warfare
  225. Move3
  226.           gosub savemove
  227.           if count=1 gosub zerocoords:ta=ta+1
  228.           count=count+1:if count=nm+1 gosub showchar:return
  229.           goto Move1
  230.  
  231. showchar
  232.           x=xx:y=sy:gosub screen
  233.           print aa$      ;
  234.           return
  235.  
  236. zerocoords
  237.           close #1:open #1,"h:coords"
  238.           position #1,8,kc-1:print #1,0,0
  239.           close #1:open #1,"H:WAR.MAP1"
  240.           return
  241.  
  242. savemove
  243.           if (bt=1) and (c$<>":") d$="+"
  244.           if (bt=1) and (c$=":") d$=":"
  245.           if (bt=0) and (asc(aa$)>96) d$=" "
  246.           if (asc(aa$)>64) and (asc(aa$)<91) d$=aa$
  247.           if instr(c$,pc$) goto save2
  248.           if (c$="*") or ((asc(c$)>64) and (asc(c$)<91)) ct=ct+1
  249. save2
  250.           if (c$="*") or ((asc(c$)>64) and (asc(c$)<91)) aa$=chr$(asc(aa$)-32):else if ((asc(aa$)>64) and (asc(aa$)<91)) aa$=chr$(asc(aa$)+32)
  251.           position #1,80,yy-1,xx-1
  252.           print #1,aa$   ;
  253.           if (c$="+") and (bt=0) bb$=chr$(val(bb$)+64)
  254.           if (c$<>":") and (c$<>"+") and (bt=1) bb$=chr$(asc(bb$)-16)
  255.           position #2,80,yy-1,xx-1
  256.           print #2,bb$   ;
  257.           position #2,80,yf-1,xf-1
  258.           print #2,"0"   ;
  259.           position #1,80,yf-1,xf-1
  260.           print #1,d$    ;
  261.           x=xf:y=ys:gosub screen:print d$;
  262.           x=xx:y=sy:gosub screen:gosub invon:print aa$;:gosub invoff
  263.           return
  264.  
  265. upnew
  266.           p1=(instr(p1$,"ABCDEF"))-1
  267.           p2=(instr(p2$,"ABCDEF"))-1
  268.           close #1:open #1,"h:attacks"
  269.           position #1,60,p1,10*p2
  270.           input #1,qn
  271.           qn=qn+1
  272.           position #1,60,p1,10*p2
  273.           print #1,qn
  274. uptot
  275.           p1=(instr(p1$,"ABCDEF"))-1
  276.           p2=(instr(p2$,"ABCDEF"))-1
  277.           close #1:open #1,"h:attacks"
  278.           position #1,60,p1,(10*p2)+5
  279.           input #1,qt
  280.           qt=qt+1
  281.           position #1,60,p1,(10*p2)+5
  282.           print #1,qt
  283.           close #1
  284.           open #1,dr$+"game.data."+gn$
  285.           position #1,1,p2*5+300
  286.           input #1,at
  287.           at=at-1
  288.           position #1,1,p2*5+300
  289.           print #1,at
  290.           close #1:open #1,"h:war.map1"
  291.           return
  292. upboat
  293.           p1=(instr(p1$,"ABCDEF"))-1
  294.           close #1:open #1,dr$+"game.data."+gn$
  295.           position #1,1,p1*5+300:input #1,at:at=at-6
  296.           position #1,1,p1*5+300:print #1,at:close #1:open #1,"h:war.map1"
  297.           return
  298.  
  299. losecity
  300.           p2=(instr(p2$,"ABCDEF"))-1
  301.           close #1:open #1,dr$+"game.data."+gn$
  302.           position #1,1,p2*5+270
  303.           input #1,at
  304.           at=at-1
  305.           position #1,1,p2*5+270
  306.           print #1,at
  307.           close #1:open #1,"h:war.map1"
  308.           return
  309.  
  310. warfare
  311.           gosub armystrength:hs=ar:hs$=mid$(l2$,xx,1)
  312.           if hs=0 x=40:y=24:gosub screen:print "City captured!           Press a key -> ";:p2$=c$:gosub losecity:gosub getkey:goto move3
  313.           x=1:y=24:gosub screen:print "Attacking - You:"as"  Him:"hs"              ";
  314.           kk=as
  315.           i=1
  316. warfare1
  317.           x=30:y=24:gosub screen:print "Army #"i"  ";
  318.           gosub rndm
  319.           if (asc(c$)<91) and (asc(c$)>64) zl=zl-10
  320.           if (as>hs) zl=zl+((as-hs)*3)
  321.           if (hs>as) zl=zl-((hs-as)*3)
  322.           if zl<=20 print "Your army killed!                        ";:as=as-1:p1$=c$:p2$=aa$:gosub uptot:goto warfare2
  323.           if zl<=50 print "Both armies killed!                     ";:hs=hs-1:as=as-1:p1$=c$:p2$=aa$:gosub uptot:p1$=aa$:p2$=c$:gosub upnew:goto warfare2
  324.           if zl<=80 print "Attack repelled!                         ";:goto warfare2
  325.           print "His army killed!                         ";:hs=hs-1:p1$=aa$:p2$=c$:gosub upnew
  326. warfare2
  327.           x=17:y=24:gosub screen:print as;" ";:x=24:gosub screen:print hs;" ";
  328.           x=58:y=24
  329.           if (as=0) or (hs=0) or (i=kk) gosub screen:print" Attack over-Hit a key";:gosub getkey:goto warend
  330.           x=58:gosub screen:print   " ESC-Quit,<cr>-cont   ";:gosub getkey
  331.           if ka$=chr$(27) goto warend
  332.           i=i+1:goto warfare1
  333. warend
  334.           f$=aa$:g$=c$
  335.           x=1:y=24:gosub screen:print "Armies: ";hs;"       ";
  336.           x=15:gosub screen:print "Terrain: ";ms$;"                ";
  337.           if (hs=0) and (asc(hs$)<64) hs$="0"
  338.           if as=0 bb$="0"
  339.           if (hs=0) and (asc(c$)<96) and (as>0) p2$=c$:gosub losecity
  340.           if (hs=0) and (asc(hs$)>64) c$="+"
  341.           if (hs=0) and (asc(hs$)<64) and (asc(c$)>96) c$=" "
  342.           if (hs=0) and (as>0) and (bt=1) bb$=chr$(as+64):goto move3
  343.           if (hs=0) and (as>0) bb$=chr$(as+48):goto move3
  344.           if (as=0) and (bt=1) aa$="+"
  345.           if (as=0) and (bt=0) and (asc(aa$)>96) aa$=" "
  346.           if (as=0) and (hs=0) goto warwrite
  347.           if (as=0) and (asc(hs$)>64) hs$=chr$(hs+64)
  348.           if (as=0) and (asc(hs$)<64) hs$=chr$(hs+48)
  349.           if (as=0) goto warwrite
  350.           if (bt=1) bb$=chr$(as+64):else bb$=chr$(as+48)
  351.           if (asc(hs$)>64) hs$=chr$(hs+64):else hs$=chr$(hs+48)
  352. warwrite
  353.           if count=1 gosub zerocoords:ta=ta+1
  354.           position #1,80,yy-1,xx-1:print #1,c$;
  355.           position #1,80,yf-1,xf-1:print #1,aa$;
  356.           position #2,80,yy-1,xx-1:print #2,hs$;
  357.           position #2,80,yf-1,xf-1:print #2,bb$;
  358.           x=xf:y=ys:gosub screen:print aa$;
  359.           x=xx:y=sy:gosub screen:print c$;
  360.           return
  361.  
  362. getkey
  363.           ka=key(0):if ka=0 goto getkey
  364.           ka$=chr$(ka)
  365.           if asc(ka$)>96 ka$=chr$(asc(ka$)-32)
  366.           poke 99,0:poke 100,0
  367.           return
  368.  
  369. scrolldown
  370.           if (an=1) and (info(0)) print #4,"3r";
  371.           if (info(0)) and (pt=1) y=23:x=1:gosub screen:print #4,"";
  372.           x=1:y=1:gosub screen:if (info(0)) and (pt=1) print #4,"";
  373.           if (info(0)) and (an=1) print #4,"M";
  374.           close
  375.           call -25088
  376.           open #1,"h:war.map1":open #2,"h:war.map2"
  377.           y=yy-1:gosub getline1
  378.           x=1:y=1:gosub screen
  379.           print l1$      ;
  380.           ys=ys+1
  381.           ke=ke+1
  382.           tp=tp-1
  383.           if (info(0)) and (an=1) print #4,"4r";
  384.           return
  385. scrollup
  386.           if (an=1) and (info(0)) print #4,"3r";
  387.           x=1:y=1:gosub screen:if (info(0)) and (pt=1) print #4,"";
  388.           if (info(0)) and (an=1) x=79:y=23:gosub screen:print #4,""
  389.           x=1:y=23:gosub screen:if (info(0)) and (pt=1) print #4,"";
  390.           poke 35,23
  391.           y=yy+1:gosub getline1
  392.           x=1:y=23:gosub screen:print #3
  393.           gosub screen
  394.           print l1$      ;
  395.           poke 35,24
  396.           tp=tp+1
  397.           ys=ys-1
  398.           ke=ke-1
  399.           if (info(0)) and (an=1) print #4,"4r";
  400.           return
  401. map2
  402.           if (ka$="K") and (xx<70) xx=xx+10:gosub erase:goto mapmv2
  403.           if (ka$="J") and (xx>10) xx=xx-10:gosub erase:goto mapmv2
  404.           if (ka$="I") and (sy>5) sy=sy-4:yy=yy-4:gosub erase:goto mapmv2
  405.           if (ka$="M") and (sy<19) sy=sy+4:yy=yy+4:gosub erase:goto mapmv2
  406.           if (ka$="I") and (tp>5) gosub erase:yy=tp-4:gosub scr1:sy=(yy-tp)+1:so=sy:xo=xx:yo=yy:goto mapmv2
  407.           if (ka$="M") and (tp<20) gosub erase:yy=tp+26:gosub scr2:sy=(yy-tp)+1:so=sy:xo=xx:yo=yy:goto mapmv2
  408.  
  409. mapmove
  410.           gosub getkey
  411.           if instr(ka$,"IJKM") kk=1:else kk=0
  412.           if (kk) and (ok=0) goto map2
  413.           if instr(ka$,"147QAZ") ml=1:else ml=0
  414.           if instr(ka$,"369CDE") mr=1:else mr=0
  415.           if (ml) and (xx<>1) xx=xx-1:gosub erase
  416.           if (mr) and (xx<79) xx=xx+1:gosub erase
  417.           if instr(ka$,"QE79") ka$="8":else if instr(ka$,"ZC13") ka$="2"
  418.           if ((ka$="8") or (ka$='W')) and (sy<=2) and (yy>2) gosub erase:yy=yy-1:gosub scrolldown:xo=xx:yo=yy:so=sy:goto mapmv2
  419.           if ((ka$="2") or (ka$='X')) and (sy>=22) and (yy<45) gosub erase:yy=yy+1:gosub scrollup:xo=xx:yo=yy:so=sy:goto mapmv2
  420.           if ((ka$="8") or (ka$='W')) and (sy>2) yy=yy-1:sy=sy-1:gosub erase:goto mapmv2
  421.           if ((ka$="2") or (ka$='X')) and (sy<22) yy=yy+1:sy=sy+1:gosub erase:goto mapmv2
  422.           if ((ka$="8") or (ka$='W')) and (yy=2) goto mapmove
  423.           if ((ka$="2") or (ka$='X')) and (yy=45) goto mapmove
  424. mapmv2
  425.           if ka$=chr$(27) return
  426.           if (ka$=chr$(13)) and (ok=0) return
  427.           if instr(ka$," YN5") return
  428.           y=yy:gosub getline1
  429.           x=xx:y=sy:gosub screen:gosub invon:print mid$(l1$,xx,1);chr$(8);:gosub invoff
  430.           if instr(ka$,"QWEADSZXC789456123<>,.") kk=1:else kk=0
  431.           if (ok) and (kk) ok=0:return
  432.           if instr(mid$(l1$,xx,1),"ABCDEF") x=9:y=24:gosub screen:gosub armystrength:print ar;" ";:else if ar<>0 x=9:y=24:gosub screen:print "0";:ar=0
  433.           if mid$(l1$,xx,1)<>tr$ gosub getterrain:x=24:y=24:gosub screen:print ms$;
  434.           x=xx:y=sy:gosub screen
  435.           goto mapmove
  436.  
  437. getterrain
  438.           a$=mid$(l1$,xx,1):if instr(a$,"ABCDEF") am=1:else am=0
  439.           y=yy:gosub getline2:b$=mid$(l2$,xx,1)
  440.           if a$="#" ms$="Impassable"
  441.           if a$=" " ms$="Land      "
  442.           if a$=":" ms$="Water     "
  443.           if a$="+" ms$="Empty Boat"
  444.           if a$="=" ms$="Deep Water"
  445.           if a$="*" ms$="City      "
  446.           if (am) and (asc(a$)>96) and (asc(b$)<65) ms$="Army      "
  447.           if (asc(a$)>96) and (am) and (asc(b$)>64) ms$="Army/Boat "
  448.           if (asc(a$)>64) and (asc(a$)<91) ms$="Army/City "
  449.           tr$=a$
  450.           return
  451.  
  452. armystrength
  453.           y=yy:gosub getline2
  454.           a$=mid$(l2$,xx,1)
  455.           if instr(a$,"0123456789") ar=val(a$):return
  456.           if instr(a$,"ABCDEFGHI") ar=asc(a$)-64:return
  457.           ar=0:return 
  458.  
  459.                          ;
  460.                          ; Scan the map for character CH$ and records coordinates in H:COORDS
  461.                          ;
  462.  
  463. ScanMap
  464.           x=40:y=24:gosub screen
  465.           print \"Wait..scanning map...                   ";
  466.           kill "H:COORDS":create "H:COORDS"
  467.           kc=0:kb=0:if (asc(ch$)>96) and (asc(ch$)<123) kb=1:kb$=chr$(asc(ch$)-32)
  468.           for y = 2 to 45
  469.           gosub getline1:gosub getline2
  470.           ka=instr(ch$,l1$)
  471.           if not ka goto PastCheck
  472.  
  473.           for x = ka to 79
  474.           ka$=mid$(l1$,x,1)
  475.           if ch$=ka$ gosub FoundMatch
  476.           if kb and (ka$=kb$) then if val(mid$(l2$,x,1))>0 gosub FoundMatch
  477.           next
  478. PastCheck
  479.           next:nb=kc:kc=0:return
  480.  
  481. FoundMatch
  482.           close #1:open #1,"H:COORDS"
  483.           position #1,8,kc:print #1 x,y
  484.           position #1,8,kc+1:print #1 0,0
  485.           close #1:open #1,"H:WAR.MAP1"
  486.           kc=kc+1
  487.           return
  488.  
  489.  
  490.                          ;
  491.                          ; Read coordinates from "H:COORDS" and calls Move routine
  492.                          ; Make sure KC=0 before calling, and don't use KC in move routine
  493.                          ;
  494.  
  495. ReadCoords
  496.           if (ta>nb) return
  497.           close #1:open #1,"H:COORDS"
  498.           position #1,8,kc:input #1 kx,ky
  499.           close #1:open #1,"H:WAR.MAP1"
  500.           if (kx=0) and (ky=0) kc=kc+1:gosub scanback:goto readcoords
  501.           xx=kx:yy=ky
  502.           KC=KC+1
  503.           gosub move
  504.           goto ReadCoords
  505.  
  506. sback0
  507.           gosub scanback
  508.           if kd=kc x=xx:y=sy:gosub invon:gosub screen:print a$;:gosub invoff:goto move2
  509.           return
  510. Scanback
  511.           gosub erase
  512.           kk=kc:kc=kc-1
  513.           close #1:open #1,"H:coords"
  514. Sback2
  515.           kc=kc-1
  516.           if kc<0 kc=kk:close #1:open #1,"H:war.map1":return
  517.           position #1,8,kc:input #1,kx,ky
  518.           if (kx>0) and (ky>0) close #1:open #1,"h:war.map1":return
  519.           goto sback2
  520. scanforw
  521.           gosub erase
  522.           kk=kc
  523.           close #1:open #1,"h:coords"
  524. sforw2
  525.           if kc>nb kc=kk:close #1:open #1,"h:war.map1":return
  526.           position #1,8,kc:input #1,kx,ky
  527.           if (kx>0) and (ky>0) close #1:open #1,"h:war.map1":return
  528.           kc=kc+1
  529.           goto sforw2
  530.  
  531. erase
  532.           y=yo:gosub getline1
  533.           a$=mid$(l1$,xo,1)
  534.           x=xo:y=so:gosub screen
  535.           print a$       ;
  536.           xo=xx:yo=yy:so=sy
  537.           return
  538.  
  539.  
  540. pmap
  541.           gosub home
  542.           if ma=0 fn=1:else fn=24 
  543.           for y=fn to fn+22
  544.           gosub getline1
  545.           print l1$
  546.           next
  547.           goto pmap2
  548. printmap
  549.           gosub home
  550.           for y=1 to 23
  551.           gosub getline1
  552.           print l1$
  553.           next
  554. pmap2
  555.           x=xx:y=sy:gosub getline1:gosub armystrength
  556.           x=1:y=24:gosub screen:print "Armies: ";ar;" ";
  557.           x=15:gosub screen:print "Terrain: ";ms$;
  558.           return
  559.  
  560. Screen
  561.           print #3 chr$(30);chr$(31+x);chr$(31+y);
  562.           if (pt) print #4 chr$(30);chr$(31+x);chr$(31+y);
  563.           if AN print #4 chr$(27); "["y";"x"f";
  564.           return
  565.  
  566. InvOn
  567.           print #3 chr$(15);
  568.           if (pt) print #4 chr$(15);
  569.           if an print #4 chr$(27);"[1m";
  570.           return
  571.  
  572. InvOff
  573.           print #3 chr$(14);
  574.           if (pt) print #4 chr$(14);
  575.           if an print #4 chr$(27);"[0m";
  576.           return
  577.  
  578. Home
  579.           print #3 chr$(12);
  580.           if (pt) print #4 chr$(12);
  581.           if an print #4 chr$(27);"[H";chr$(27);"[J";
  582.           return
  583.  
  584. rndm
  585.           zl$=rnd$
  586.           zl=((random(10000)+100)/100):if zl>100 then zl=zl-1
  587.           return
  588.  
  589. getline1
  590.           free
  591.           position #1,80,y-1
  592.           input #1,l1$
  593.           return
  594. getline2
  595.           position #2,80,y-1
  596.           input #2,l2$
  597.           return
  598.  
  599. link.term
  600.           link "a:war.start","termgame"
  601.